// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Funky Funky Player
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 1 : TYPE_PLAYEROBJECT
public alias 256 : GROUP_PLAYERS
public alias 65536 : HITBOX_AUTO
public alias arrayPos6 : currentPlayer
public alias arrayPos7 : playerCount


public value PlayerObject_SuperState = 0;
public value PlayerObject_value1 = 0;
public value PlayerObject_value2 = 0;
public value PlayerObject_value3 = 0;
public value PlayerObject_value4 = 0;
public value PlayerObject_value5 = 0;
public value PlayerObject_value6 = 0;

//0 = Left
//1 = Down
//2 = Up
//3 = Right
//4 = Blank



event ObjectMain


	if inputpress[0].right == 1
		print("3,", false, true)
	end if

	if inputpress[0].left == 1
		print("0,", false, true)
	end if

	if inputpress[0].up == 1
		print("2,", false, true)
	end if

	if inputpress[0].down == 1
		print("1,", false, true)
	end if

	CheckEqual(inputpress[0].right, 0)
	temp0 = checkResult
	CheckEqual(inputpress[0].left, 0)
	temp0 &= checkResult
	CheckEqual(inputpress[0].up, 0)
	temp0 &= checkResult
	CheckEqual(inputpress[0].down, 0)
	temp0 &= checkResult	
	if temp0 == 1
		print("4,", false, true)
	end if		

	switch object.state 
		case 0
			ProcessAnimation()

			object.animation = ANI_STOPPED
			object.direction = 1
			object.animationSpeed = 0
			object.animationTimer = 0

			if object[0].controlmode >= 0	
				if inputdown[0].right == 1
					object.animation = ANI_SKIDDING
				//	Print(message, bool isInt, bool useEndLine)
				end if

				if inputdown[0].left == 1
					object.animation = ANI_FLAILING1
				end if

				if inputdown[0].up == 1
					object.frame = 2
					object.animation = ANI_LOOKINGUP
				end if

				if inputdown[0].down == 1
					object.frame = 2
					object.animation = ANI_LOOKINGDOWN
				end if
				
				if inputpress[0].buttonX == 1
					object.speed = 0
					object.yvel = -0x70000
					object.xvel = 0
					PlaySfx(SfxName[Hurt], 0)	
					object.state = 1
					object.animation = ANI_DYING
					object.tileCollisions = 0
					object.interaction = 0
				end if
			end if
		break
		case 1
			screen.cameraX = object.ixpos
		break
	end switch

	Stage.curYBoundary2 = 0x141
end event

event ObjectDraw
	DrawObjectAnimation()
end event


event ObjectStartup
	foreach (TypeName[Funky Player], arrayPos0, ALL_ENTITIES)
		screen.cameraEnabled = 1
		screen.cameraStyle = 4
		screen.cameraTarget = 0
		currentPlayer = 0
		ResetObjectEntity(0, TypeName[Funky Player], 0, object[arrayPos0].xpos, object[arrayPos0].ypos)
		temp0 = object[0].ixpos
		temp0 -= 64
		screen.cameraX = temp0
		screen.cameraY = object[0].iypos
		object[0].groupID = GROUP_PLAYERS
		object[0].state = 0
		object[0].priority = PRIORITY_ACTIVE
		object[0].drawOrder = 5
		object[0].value18 = 4
		object[0].value31 = 0x2000
		object[0].value38 = HITBOX_AUTO
		object[0].value39 = HITBOX_AUTO
		object[0].value40 = HITBOX_AUTO
		object[0].value41 = HITBOX_AUTO
		object[0].controlmode = -1

		LoadAnimation("Sonic.ani")
		object[0].propertyValue = 0

		currentPlayer = 0
		ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
	next
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
